---
layout: page
title: 分类
tagline: 按照所属类别展示
header: Posts By Category
ctg: true
permalink: /categories/
comments: false
---
{% include JB/setup %}

{% assign x_label = '分类' %}
{% assign y_label = '数目' %}

{% assign list = nil %}

{% assign p_ctg_list = "" %}
{% for category in site.data.categories %}
  {% assign name = category.name %}
  {% assign downcase_name = name | downcase %}
  {% assign categories = site.categories[downcase_name] %}
  {% assign size = categories.size %}
  <h2 id="{{ downcase_name | replace:" ","-" | replace:"/","-" }}-ref">{{ name }}{% if size %} <sup>({{ size }})</sup>{% endif %}</h2>

  {% if size %}
  {% assign p_ctg_list = p_ctg_list | append:"," | append:downcase_name %}
  <ul>
    {% assign pages_list = categories %}
    {% include JB/pages_list %}
  </ul>
   {% assign list0 = size | append:',' | append: name %}
   {% if list == nil %}
     {% assign list = list0 %}
   {% else %}
     {% assign list = list | append:';' | append: list0 %}
   {% endif %}

  {% endif %}

  <!-- top -->
  {% if category.categories %}
    {% for child in category.categories %}
      {% assign name = child.name %}
      {% assign downcase_name = name | downcase %}
      {% assign child_categories = site.categories[downcase_name] %}
      {% assign size = child_categories.size %}
      <h3 id ="{{ downcase_name | replace:" ","-" | replace:"/","-" }}-ref">{{ name }}{% if child_size %} <sup>({{ size }})</sup>{% endif %}</h3>

      {% if size %}
      {% assign p_ctg_list = p_ctg_list | append:"," | append:downcase_name %}
        <ul>
          {% assign pages_list = child_categories %}
          {% include JB/pages_list %}
        </ul>
       {% assign list0 = size | append:',' | append: name %}
       {% if list == nil %}
         {% assign list = list0 %}
       {% else %}
         {% assign list = list | append:';' | append: list0 %}
       {% endif %}

      {% endif %}

      <!-- child -->
      {% if child.categories %}
          {% for g in child.categories %}

            {% assign name = g.name %}
            {% assign downcase_name = name | downcase %}
            {% assign g_categories = site.categories[downcase_name] %}
            {% assign size = g_categories.size %}
            <h4 id="{{ downcase_name | replace:" ","-" | replace:"/","-" }}-ref">{{ name }}{% if size %} <sup>({{ size }})</sup>{% endif %}</h4>
            {% if size %}
              {% assign p_ctg_list = p_ctg_list | append:"," | append:downcase_name %}
                <ul>
                  {% assign pages_list = g_categories %}
                  {% include JB/pages_list %}
                </ul>
               {% assign list0 = size | append:',' | append: name %}
               {% if list == nil %}
                 {% assign list = list0 %}
               {% else %}
                 {% assign list = list | append:';' | append: list0 %}
               {% endif %}

            {% endif %}

              <!-- g -->
              {% if g.categories %}

                  {% for gg in g.categories %}

                    {% assign name = gg.name %}
                    {% assign downcase_name = name | downcase %}
                    {% assign gg_categories = site.categories[downcase_name] %}
                    {% assign size = gg_categories.size %}
                    <h5 id="{{ downcase_name | replace:" ","-" | replace:"/","-" }}-ref">{{ name }}{% if size %} <sup>({{ size }})</sup>{% endif %}</h5>

                    {% if size %}
                    {% assign p_ctg_list = p_ctg_list | append:"," | append:downcase_name %}
                      <ul>
                        {% assign pages_list = gg_categories %}
                        {% include JB/pages_list %}
                      </ul>
                       {% assign list0 = size | append:',' | append: name %}
                       {% if list == nil %}
                         {% assign list = list0 %}
                       {% else %}
                         {% assign list = list | append:';' | append: list0 %}
                       {% endif %}

                    {% endif %}

                  {% endfor %}
              <!-- child end -->
              {% endif %}

          {% endfor %}

      <!-- child end -->
      {% endif %}

    {% endfor %}
  <!-- top end -->
  {% endif %}
{% endfor %}

<h2 id="其他分类-ref">其他分类</h2>

{% assign p_ctg_list = p_ctg_list | split:"," %}
{% for category in site.categories %}
  {% assign name = category[0] %}
  {% if p_ctg_list contains name %}
    {% continue %}
  {% endif %}

  {% assign size = category[1].size %}
  <h3 id="{{ name | downcase | replace:" ","-" | replace:"/","-" }}-ref">{{ name | join: "/" }} <sup>({{ size }})</sup></h3>
  <ul>
    {% assign pages_list = category[1] %}
    {% include JB/pages_list %}
  </ul>
  {% if size %}
   {% assign list0 = size | append:',' | append: name %}
   {% if list == nil %}
     {% assign list = list0 %}
   {% else %}
     {% assign list = list | append:';' | append: list0 %}
   {% endif %}
  {% endif %}

{% endfor %}

{% assign list = list | split:';' | sort | reverse | join:';' %}

<h2 id="{{x_label}}统计-ref">{{ x_label}}统计 <sup>({{ site.posts.size }})</sup></h2>
{% include widgets/svg_statistic %}
